/**
 * @autor Carlos E. AgÃ¼ero
 * GSyC 2008/2009
 * 
 */
package Flight;

import java.io.Serializable;
import java.util.*;

public class DepartureFlight extends Flight implements Comparable<Object>{
	
	private String desk, boardingGate;
	private Calendar boardingTime;
	
	public DepartureFlight(DepartureFlight f) {
		super(f.departureTime,f.arrivalTime,f.flightNumber,
				f.source,f.destination,f.status);
		this.desk = f.desk.toString();
		this.boardingTime = (Calendar)f.boardingTime.clone();
		this.boardingGate = f.boardingGate.toString();
	}
	
	public DepartureFlight (Calendar depTime, Calendar arrTime, String number, String src,
			String dst, String st, String desk, Calendar brdTime, String gate ){
		
		super(depTime,arrTime,number,src,dst,st);
		this.desk = desk.toString();
		this.boardingTime = (Calendar)brdTime.clone();
		this.boardingGate = gate.toString();
	}

	public String getDesk(){return desk;}
	public Date getBoardingTime(){return boardingTime.getTime();}
	public String getBoardingGate(){return boardingGate;}
	
	public String toString(){
		return flightNumber + " " + status + " " 
				+ departureTime.getTime() + " " + 
				destination + " " + boardingGate + " " + 
				boardingTime.getTime() + " " + desk;
	}
	
	/*public String toString(){
		return "Departure time: " + departureTime.getTime() + "\n" +
		"Destination: " + destination + "\n" +
		"Flight number: " + flightNumber + "\n" +
		"Facturation desk: " + desk + "\n" +
		"Boarding time: " + boardingTime.getTime() + "\n" +
		"Gate: " + boardingGate + "\n" +
		"Status: " + status + "\n";
	}*/
	
	public String serialize(){
		return "departureType" + "\t" +
		departureTime.getTime().getYear() + "\t" +
		departureTime.getTime().getMonth() + "\t" + 
		departureTime.getTime().getDate() + "\t" + 
		departureTime.getTime().getHours() + "\t" + 
		departureTime.getTime().getMinutes() + "\t" + 
		arrivalTime.getTime().getYear() + "\t" +
		arrivalTime.getTime().getMonth() + "\t" + 
		arrivalTime.getTime().getDate() + "\t" + 
		arrivalTime.getTime().getHours() + "\t" + 
		arrivalTime.getTime().getMinutes() + "\t" +
		flightNumber + "\t" +
		source + "\t" +
		destination + "\t" +
		status + "\t" +
		desk + "\t" +
		boardingTime.getTime().getYear() + "\t" +
		boardingTime.getTime().getMonth() + "\t" + 
		boardingTime.getTime().getDate() + "\t" + 
		boardingTime.getTime().getHours() + "\t" + 
		boardingTime.getTime().getMinutes() + "\t" +
		boardingGate;
	}
	
	public int compareTo (Object arg0) {
		if (getFlightNumber().equals(((Flight)arg0).getFlightNumber()))
			return 0;
		else
			return departureTime.getTime().compareTo(((Flight)arg0).getDepartureTime().getTime());
	}
}